package org.example.config;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;
import org.example.fault.retry.RetryStrategyKeys;
import org.example.loadbalancer.LoadBalancerKeys;
import org.example.serializer.Serializer;

/**
 * @description Rpc框架配置
 * @author sats@jz
 * @date 2024年12月25日 10:44
 */
@Data
@AllArgsConstructor
@NoArgsConstructor

//@Builder
//@Jacksonized
public class RpcConfig {

    private String name = "JZ-RPC";
    private String version = "1.0";
    private String serverHost = "localhost";
    private Integer serverPort = 8080;
    private boolean mock = false;
    private String serializer = "org.example.serializer.JdkSerializer";
    private String serializerName = "jdk";
    private RegistryConfig registryConfig = new RegistryConfig();
    private String loadBalancer = LoadBalancerKeys.ROUND_ROBIN;
    private String protocol = "tcp";
    private String retryStrategy = RetryStrategyKeys.NO_RETRY;
//    private String configName = "application.properties";

//    public Serializer getSerializer() {
//        try {
//            Class<?> clazz = Class.forName(serializer);
//            return (Serializer) clazz.getDeclaredConstructor().newInstance();
//        } catch (Exception e) {
//            throw new RuntimeException("Failed to create serializer: " + serializer, e);
//        }
//    }
}
